package com.zmn.plat.services.impl.orderconfig.returnvisitcontent;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.common.dto.StatusDTO;
import com.zmn.common.utils.date.DateUtil;
import com.zmn.plat.model.entity.orderconfig.returnvisitcontent.ReturnVisitContent;
import com.zmn.plat.model.entity.orderconfig.returnvisitcontent.ReturnVisitContentQuery;
import com.zmn.plat.persistence.interfaces.orderconfig.returnvisitcontent.ReturnVisitContentDAO;
import com.zmn.plat.services.interfaces.orderconfig.returnvisitcontent.ReturnVisitContentService;

/**
 * 类描述:回访内容service实现类
 *
 * @author linfeng
 * @since 2019/10/24/9:45
 */
@Service
public class ReturnVisitContentServiceImpl implements ReturnVisitContentService {

    @Resource
    ReturnVisitContentDAO returnVisitContentDao;

    @Override
    public Integer countByQuery(ReturnVisitContentQuery query) {
        return returnVisitContentDao.countByQuery(query);
    }

    @Override
    public ReturnVisitContent findByKey(Integer id) {
        return returnVisitContentDao.findByKey(id);
    }

    @Override
    public List<ReturnVisitContent> listPageByQuery(ReturnVisitContentQuery query) {
        int count = returnVisitContentDao.countByQuery(query);
        query.setTotalCount(count);
        return returnVisitContentDao.listPageByQuery(query);
    }

    @Override
    public List<ReturnVisitContent> listByQuery(ReturnVisitContentQuery query) {
        return returnVisitContentDao.listByQuery(query);
    }

    @Override
    public int updateStatusBatch(List<Integer> arrayIds, int status, String updater) {
        StatusDTO dto = new StatusDTO();
        dto.setIds(arrayIds);
        dto.setStatus(status);
        dto.setUpdater(updater);
        dto.setUpdateTime(DateUtil.getNow());
        return returnVisitContentDao.updateStatusBatch(dto);
    }

    @Override
    public Integer updateSortKey(int id, int sort, String updater) {
        ReturnVisitContent returnVisitContent = new ReturnVisitContent();
        returnVisitContent.setId(id);
        returnVisitContent.setSort(sort);
        returnVisitContent.setUpdater(updater);
        returnVisitContent.setUpdateTime(DateUtil.getNow());
        return returnVisitContentDao.updateSortKey(returnVisitContent);
    }

    @Override
    public Integer updateFirstLetterByKey(int id, String firstLetter, String updater) {
        ReturnVisitContent returnVisitContent = new ReturnVisitContent();
        returnVisitContent.setId(id);
        returnVisitContent.setFirstLetter(firstLetter);
        returnVisitContent.setUpdater(updater);
        returnVisitContent.setUpdateTime(DateUtil.getNow());
        return returnVisitContentDao.updateFirstLetterByKey(returnVisitContent);
    }

    @Override
    public Integer insert(ReturnVisitContent returnVisitContent) {
        return returnVisitContentDao.insert(returnVisitContent);
    }

    @Override
    public Integer updateByKey(ReturnVisitContent returnVisitContent) {
        return returnVisitContentDao.updateByKey(returnVisitContent);
    }
}
